<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>首页三</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="/lib/font-awesome-4.7.0/css/font-awesome.min.css" media="all">
    <link rel="stylesheet" href="/css/public.css" media="all">
    <style>
        .top-panel {
            border: 1px solid #eceff9;
            border-radius: 5px;
            text-align: center;
        }

        .top-panel > .layui-card-body {
            height: 60px;
        }

        .top-panel-number {
            line-height: 60px;
            font-size: 30px;
            border-right: 1px solid #eceff9;
        }

        .top-panel-tips {
            line-height: 30px;
            font-size: 12px
        }
    </style>
</head>
<body>
<!--<div class="layuimini-container">-->
<div class="layuimini-main">

    <div class="layui-row layui-col-space15">
        <div class="layui-col-xs12 layui-col-md9">
            <div id="echarts-records" style="background-color:#ffffff;min-height:400px;padding: 10px"></div>
        </div>

    </div>

<!--    <div class="layui-row layui-col-space15">-->
<!--        <div class="layui-col-xs12 layui-col-md6">-->
<!--            <div id="echarts-dataset" style="background-color:#ffffff;min-height:300px;padding: 10px"></div>-->
<!--        </div>-->
<!--    </div>-->


</div>
<!--</div>-->
<script src="/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script src="/js/lay-config.js?v=1.0.4" charset="utf-8"></script>
<script>
    layui.use(['layer', 'jquery', 'echarts'], function () {
        var $ = layui.jquery,
            layer = layui.layer,
            echarts = layui.echarts;

        $.ajax({
            url: 'http://192.168.100.222:8082/agent/chart.do',
            type: "post",
            dataType: "json",
            success: function (rec) {
                console.log("MR" + rec.data);
                let data = rec.data;

                let username = [];
                let num = [];
                let reward = [];


                bbq:
                    for (let dataKey of rec.data) {
                        console.log(JSON.stringify(dataKey));
                        username.push(dataKey.userName);
                        num.push(dataKey.num);
                        reward.push(dataKey.reward)
                    }
                console.log(username);
                console.log(num);
                console.log(reward);

                /**
                 * MP报表功能
                 */
                var echartsRecords = echarts.init(document.getElementById('echarts-records'), 'walden');

                var optionRecords = {
                    title: {
                        text: '提成'
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'cross',
                            label: {
                                backgroundColor: '#6a7985'
                            }
                        }
                    },

                    toolbox: {
                        feature: {
                            saveAsImage: {}
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    xAxis: [
                        {
                            type: 'category',
                            boundaryGap: false,
                            data: username
                        }
                    ],
                    yAxis: [
                        {
                            type: 'value'
                        }
                    ],
                    series: [
                        {
                            name: '提成',
                            type: 'line',
                            stack: '总量',
                            areaStyle: {},
                            data: reward
                        },
                    ]
                };
                echartsRecords.setOption(optionRecords);
                // echarts 窗口缩放自适应
                window.onresize = function () {
                    echartsRecords.resize();
                };
            }
        });
    });
</script>
</body>
</html>
